<link href="admin.css" rel="stylesheet" type="text/css" />
<script src="<{$config.weburl}>/script/jquery-1.4.4.min.js" type="text/javascript" charset="utf-8" ></script>
<script type="text/javascript">
	$(function(){
		/* 全选 */
		 $('.checkall').click(function(){
			var _self = this;
			$('.checkitem').each(function(){
				if (!this.disabled)
				{
					$(this).attr('checked', _self.checked);
				}
			});
			$('.checkall').attr('checked', this.checked);
		});	 
	});
</script>
<div class="container dialog" style="width:94%; margin:auto;">
<form action="" method="get">
<input type="hidden" name="m" value="<{$smarty.get.m}>">
<input type="hidden" name="s" value="<{$smarty.get.s}>">
<input type="hidden" name="id" value="<{$smarty.get.id}>">
<input type="hidden" name="type" value="<{$smarty.get.type}>">
<table class="table select_table" style="margin-bottom:0;">
    <tbody>
    	<tr>
            <td width="70">产品名称:</td>
            <td width="210"><input type="text" name="key" class="w200" value="<{$smarty.get.key}>" /></td>
			<td width="70">产品分类:</td>
            <td>
            <select name="catid">
            	<option value="">选择分类</option>
                <{foreach item=list from=$re}>
                	<option  <{if $smarty.get.catid==$list.catid}>selected="selected"<{/if	}> value="<{$list.catid}>"><{$list.cat}></option>
                <{/foreach}>
            </select>
            </td>
            <td width="70">产品标签:</td>
            <td>
            <select name="tags">
            	<option value="">选择标签</option>
                <{foreach item=list from=$de.all_tags}>
                        
             			<option <{if  @$list.id|in_array:$de.tags}> selected="selected" <{/if}> value="<{$list.id}>"><{$list.tags}></option>
                           
                            <{foreach item=slist from=$list.stags}>
                            <option  <{if @$slist.id|in_array:$de.tags}> selected="selected" <{/if}> value="<{$slist.id}>">|__<{$slist.tags}></option>
                            	    
                                    <{foreach item=sslist from=$slist.stags}>
                                    <option <{if @$sslist.id|in_array:$de.tags}> selected="selected" <{/if}> value="<{$sslist.id}>">|____<{$sslist.tags}></option>
                                    
                                    <{foreach item=lists from=$sslist.stags}>
                                    <option <{if @$lists.id|in_array:$de.tags}> selected="selected" <{/if}> value="<{$lists.id}>">|______<{$lists.tags}></option>
                            		<{/foreach}>
                            		<{/foreach}> 
                                    
                            <{/foreach}> 
                            
                        <{/foreach}> 
            </select>
            </td>
        </tr>
        <tr>    
            <td width="70">产品编号:</td>
            <td width="210"><input type="text" name="code" class="w200" value="<{$smarty.get.code}>" /></td>
            <td width="50">产品ID:</td>
            <td width="100"><textarea name="product_id" style="resize:horizontal;height:30px;"><{$smarty.get.product_id}></textarea></td>
            <td width="70">品牌:</td>
            <td>
                <input type="hidden" name="brandid" id="brandid" value="<{$smarty.get.brandid}>"/>
            	<input style="width:100px;" type='text' name='brand' id='brand' value="<{$smarty.get.brand}>" placeholder='输入搜索词' autocomplete="off"/>
            	<ul id="brandlist" style="display:none;position:absolute;background-color:#fff;border: 1px solid rgb(207, 201, 201);width: 98px;">
       			</ul>
            </td>
            <td colspan="2"><input type="image" src="<{$config.weburl}>/image/admin/search.gif" /></td>
        </tr>
    </tbody>
</table>
</form>
<form action="" method="post">
<table class="table alc" id="<{$smarty.get.type}>_table">
    <tbody>
        <tr class="header">
            <th width="20"></th>
            <th class="150">产品ID</th>
            <th class="al">产品名称</th>
            <th width="100" class="al">产品编号</th>
            <th width="100">产品分类</th>
            <th width="100">产品标签</th>
            <th width="100">所属品牌</th>
            <th width="70">销售价</th>
            <th width="70">市场价</th>
            <!-- <th width="70">税率</th> -->
        </tr>
        <{foreach item=list key=num from=$de.list}>
        <tr>
            <td>
            <input type="radio" value="<{$list.id}>,<{$list.pid}>,<{$list.pname}> <{$list.spec}>,<{$list.price}>,<{$list.market_price}>,<{$list.stock}>" class="checkitem" name="chk">
            </td>
            <td width="150"><{$list.pid}></td>
            <td class="al td250">
            <div class="name" title="<{$list.pname}>"><{$list.pname}> <{$list.spec}></div>
            </td>
            <td class="al"><{$list.code}></td>
            <td><{$list.catname}></td>
            <td><{$list.tagnames}></td>
            <td><{$list.brand}></td>
            <td><{$list.price}></td>
            <td><{$list.market_price}></td>
            <!-- <td><{$list.tax_rate}></td> -->
        </tr>
        <{foreachelse}>
        <tr>
            <td class="norecord" colspan="99"><i></i><span>暂无符合条件的数据记录</span></td>
        </tr>
        <{/foreach}>
    </tbody>
    <tfoot>        
          <tr>
            <td colspan="2" class="al">
                <div class="del">
                <input type="checkbox" class="checkall" id="del">
                <label for="del">&nbsp;&nbsp;全选</label>
                </div>
				<input type="hidden" name="id" value="<{$smarty.get.id}>" />
				<input type="hidden" name="type" value="<{$smarty.get.type}>">
                <input type="hidden" name="act" value="add" />
                <input type="submit" name="activity_button" value="添加" />
            </td>
            <td colspan="99"><div class="page"><{$de.page}></div></td>
        </tr>
    </tfoot>
</table>
</form>
<script>
//默认待选品牌
$('#brand').bind('click',function(e){
		$.get('<{$config.weburl}>/admin/module.php?m=activity&s=activity.php&operation=getbrand&brandname=',function(data){
			$('#brandlist').show();
			$('#brandlist').html(""+data);
		});
});
//直接搜品牌
$('#brand').bind('input',function(e){
	var value=$(this).val();
	if(value==''){
		$('#brandlist').hide();
		return ;
	}
	else{
		$.get('<{$config.weburl}>/admin/module.php?m=activity&s=activity.php&operation=getbrand&brandname='+value,function(data){
			$('#brandlist').show();
			$('#brandlist').html(""+data);
		});
	}
});
$('body').bind('click',function(e){
	$('#brandlist').hide();
});
$('#brandlist').delegate('li','click',function(){
	var _this=$(this);
	var brandName=_this.text();
		var brandId=_this.attr('bid');
		$('#brand').val(brandName);
		$('#brandid').val(brandId);
		$('#brandlist').hide();
});

$.each($('[stock]'),function(){
	//alert($(this).attr('stock'));
	var $stock=$(this);
	
	$.get('<{$config.weburl}>/admin/module.php?m=product&s=inventory_api.php&stock='+$(this).attr('stock'),function(data){
		$stock.html(data);
	});

	
});
</script>
</div>
